package com.tabjin.rfidsocket;

import com.tabjin.rfidsocket.netty.AppServer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * @author tabjin
 * create at 2020/11/12 23:29
 * @program rfid_socket
 * @description
 */
@Component
public class NettyBoot implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (contextRefreshedEvent.getApplicationContext().getParent() == null) {
            try {
                AppServer.getInstance().start();// 启动netty
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
